Change in openvpn[master]: verify_x509_name: Improve the error message on failure
A message that is not in the archive (sent off-list or not yet received): gerrit.1775698562000.I6e7947ab81cf229f0d27714dd563a07ace6bd38a@...2715...
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1624?usp=email
to review the following change.
Change subject: verify_x509_name: Improve the error message on failure
......................................................................
verify_x509_name: Improve the error message on failure
Print the actual string that was used for the match instead of the whole subject.
Github: closes OpenVPN/openvpn#992
---
M src/openvpn/ssl_verify.c
1 file changed, 22 insertions(+), 11 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/24/1624/1
src/openvpn/ssl_verify.c +22 -11
@@ -369,21 +369,32 @@/* verify X509 name or username against --verify-x509-[user]name */ if (opt->verify_x509_type !=VERIFY_X509_NONE ) { -if ((opt->verify_x509_type ==VERIFY_X509_SUBJECT_DN - &&strcmp (opt->verify_x509_name, subject) ==0 ) - || (opt->verify_x509_type ==VERIFY_X509_SUBJECT_RDN - &&strcmp (opt->verify_x509_name, common_name) ==0 ) - || (opt->verify_x509_type ==VERIFY_X509_SUBJECT_RDN_PREFIX - &&strncmp (opt->verify_x509_name, common_name,strlen (opt->verify_x509_name)) ==0 )) +const char *err_fmt ="VERIFY X509NAME ERROR: %s, must be %s" ; +const char *match_str = common_name; +bool verified = false; +switch (opt->verify_x509_type) { -msg (D_HANDSHAKE ,"VERIFY X509NAME OK: %s" , subject); +case VERIFY_X509_SUBJECT_DN : + match_str = subject; + verified = !strcmp (opt->verify_x509_name, match_str); +break ; +case VERIFY_X509_SUBJECT_RDN : + verified = !strcmp (opt->verify_x509_name, match_str); +break ; +case VERIFY_X509_SUBJECT_RDN_PREFIX : + err_fmt ="VERIFY X509NAME ERROR: %s, must start with %s" ; + verified = !strncmp (opt->verify_x509_name, match_str,strlen (opt->verify_x509_name)); +break ; +default : +ASSERT (0 );/* should not happen */ +break ; } -else +if (!verified) { -msg (D_HANDSHAKE ,"VERIFY X509NAME ERROR: %s, must be %s" , subject, - opt->verify_x509_name); -return FAILURE ;/* Reject connection */ +msg (D_HANDSHAKE , err_fmt, match_str, opt->verify_x509_name); +return FAILURE ; } +msg (D_HANDSHAKE ,"VERIFY X509NAME OK: %s" , subject); }return SUCCESS ;
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1624?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6e7947ab81cf229f0d27714dd563a07ace6bd38a
Gerrit-Change-Number: 1624
Gerrit-PatchSet: 1
Gerrit-Owner: selvanair <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: plaisthos, selvanair.
ordex has posted comments on this change by selvanair. ( http://gerrit.openvpn.net/c/openvpn/+/1624?usp=email )
Change subject: verify_x509_name: Improve the error message on failure
......................................................................
Patch Set 1:
(1 comment)
File src/openvpn/ssl_verify.c:
http://gerrit.openvpn.net/c/openvpn/+/1624/comment/9a8f2a69_b9100741?usp=email :
PS1, Line 397: msg(D_HANDSHAKE, "VERIFY X509NAME OK: %s", subject);
by applying the same logic, shouldn't we just print the string we have matched against, instead of the whole subject?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1624?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6e7947ab81cf229f0d27714dd563a07ace6bd38a
Gerrit-Change-Number: 1624
Gerrit-PatchSet: 1
Gerrit-Owner: selvanair <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: selvanair <[email protected]...>
Gerrit-Comment-Date: Mon, 13 Apr 2026 09:16:12 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Attention is currently required from: ordex, plaisthos.
selvanair has posted comments on this change by selvanair. ( http://gerrit.openvpn.net/c/openvpn/+/1624?usp=email )
Change subject: verify_x509_name: Improve the error message on failure
......................................................................
Patch Set 1:
(1 comment)
File src/openvpn/ssl_verify.c:
http://gerrit.openvpn.net/c/openvpn/+/1624/comment/b73b8520_97809e57?usp=email :
PS1, Line 397: msg(D_HANDSHAKE, "VERIFY X509NAME OK: %s", subject);
Quoted 1 line
by applying the same logic, shouldn't we just print the string we have matched against, instead of t […]
Here is my thought on this:
On success, its just a gratuitous message and its not confusing. We are just printing what the subject (DN) of the certificate is. On error, its a critical message that says what was expected and what was found. The current code tries to match something and prints something else.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1624?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6e7947ab81cf229f0d27714dd563a07ace6bd38a
Gerrit-Change-Number: 1624
Gerrit-PatchSet: 1
Gerrit-Owner: selvanair <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Mon, 13 Apr 2026 17:23:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: ordex <[email protected]...>
Attention is currently required from: ordex, selvanair.
plaisthos has posted comments on this change by selvanair. ( http://gerrit.openvpn.net/c/openvpn/+/1624?usp=email )
Change subject: verify_x509_name: Improve the error message on failure
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1624?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6e7947ab81cf229f0d27714dd563a07ace6bd38a
Gerrit-Change-Number: 1624
Gerrit-PatchSet: 1
Gerrit-Owner: selvanair <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Attention: selvanair <[email protected]...>
Gerrit-Comment-Date: Mon, 13 Apr 2026 21:31:09 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
PATCH 1/1 verify_x509_name: Improve the error message on failure
In reply to a message not in the archiveFrom: Selva Nair <[email protected]...>
Print the actual string that was used for the match instead of the whole subject.
Github: closes OpenVPN/openvpn#992
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1624
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1624
This mail reflects revision 1 of this Change.
Acked-by according to Gerrit (reflected above):
Arne Schwabe <[email protected]...>
src/openvpn/ssl_verify.c +22 -11
@@ -369,21 +369,32 @@/* verify X509 name or username against --verify-x509-[user]name */ if (opt->verify_x509_type !=VERIFY_X509_NONE ) { -if ((opt->verify_x509_type ==VERIFY_X509_SUBJECT_DN - &&strcmp (opt->verify_x509_name, subject) ==0 ) - || (opt->verify_x509_type ==VERIFY_X509_SUBJECT_RDN - &&strcmp (opt->verify_x509_name, common_name) ==0 ) - || (opt->verify_x509_type ==VERIFY_X509_SUBJECT_RDN_PREFIX - &&strncmp (opt->verify_x509_name, common_name,strlen (opt->verify_x509_name)) ==0 )) +const char *err_fmt ="VERIFY X509NAME ERROR: %s, must be %s" ; +const char *match_str = common_name; +bool verified = false; +switch (opt->verify_x509_type) { -msg (D_HANDSHAKE ,"VERIFY X509NAME OK: %s" , subject); +case VERIFY_X509_SUBJECT_DN : + match_str = subject; + verified = !strcmp (opt->verify_x509_name, match_str); +break ; +case VERIFY_X509_SUBJECT_RDN : + verified = !strcmp (opt->verify_x509_name, match_str); +break ; +case VERIFY_X509_SUBJECT_RDN_PREFIX : + err_fmt ="VERIFY X509NAME ERROR: %s, must start with %s" ; + verified = !strncmp (opt->verify_x509_name, match_str,strlen (opt->verify_x509_name)); +break ; +default : +ASSERT (0 );/* should not happen */ +break ; } -else +if (!verified) { -msg (D_HANDSHAKE ,"VERIFY X509NAME ERROR: %s, must be %s" , subject, - opt->verify_x509_name); -return FAILURE ;/* Reject connection */ +msg (D_HANDSHAKE , err_fmt, match_str, opt->verify_x509_name); +return FAILURE ; } +msg (D_HANDSHAKE ,"VERIFY X509NAME OK: %s" , subject); }return SUCCESS ;
[Openvpn-devel] [PATCH applied] Re: verify_x509_name: Improve the error message on failure
With all these crypto things, figuring out why something isn't working can be hard enough as it is - without OpenVPN printing non-helpful details about "something else". I have not tested this, but just turning the if() monster into a proper switch/case and per-test message is worth the excercise :-) - Arne has ACKed it, and BB confirms "no breakage". Thanks for this.
Your patch has been applied to the master and release/2.7 branch (fixing the bug of not printing what was really matched).
commit c610746a2cceb27032c6687a33854e9967966a39 (master) commit 20b4ecd934d5632895e330af534f105b621e4124 (release/2.7)
Author: Selva Nair Date: Tue Apr 14 07:58:24 2026 +0200
verify_x509_name: Improve the error message on failure
Signed-off-by: Selva Nair <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1624
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36606.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#2) to the change originally created by selvanair. ( http://gerrit.openvpn.net/c/openvpn/+/1624?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by plaisthos
Change subject: verify_x509_name: Improve the error message on failure
......................................................................
verify_x509_name: Improve the error message on failure
Print the actual string that was used for the match instead of the whole subject.
Github: closes OpenVPN/openvpn#992
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1624
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36606.html
---
M src/openvpn/ssl_verify.c
1 file changed, 22 insertions(+), 11 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/24/1624/2
src/openvpn/ssl_verify.c +22 -11
@@ -369,21 +369,32 @@/* verify X509 name or username against --verify-x509-[user]name */ if (opt->verify_x509_type !=VERIFY_X509_NONE ) { -if ((opt->verify_x509_type ==VERIFY_X509_SUBJECT_DN - &&strcmp (opt->verify_x509_name, subject) ==0 ) - || (opt->verify_x509_type ==VERIFY_X509_SUBJECT_RDN - &&strcmp (opt->verify_x509_name, common_name) ==0 ) - || (opt->verify_x509_type ==VERIFY_X509_SUBJECT_RDN_PREFIX - &&strncmp (opt->verify_x509_name, common_name,strlen (opt->verify_x509_name)) ==0 )) +const char *err_fmt ="VERIFY X509NAME ERROR: %s, must be %s" ; +const char *match_str = common_name; +bool verified = false; +switch (opt->verify_x509_type) { -msg (D_HANDSHAKE ,"VERIFY X509NAME OK: %s" , subject); +case VERIFY_X509_SUBJECT_DN : + match_str = subject; + verified = !strcmp (opt->verify_x509_name, match_str); +break ; +case VERIFY_X509_SUBJECT_RDN : + verified = !strcmp (opt->verify_x509_name, match_str); +break ; +case VERIFY_X509_SUBJECT_RDN_PREFIX : + err_fmt ="VERIFY X509NAME ERROR: %s, must start with %s" ; + verified = !strncmp (opt->verify_x509_name, match_str,strlen (opt->verify_x509_name)); +break ; +default : +ASSERT (0 );/* should not happen */ +break ; } -else +if (!verified) { -msg (D_HANDSHAKE ,"VERIFY X509NAME ERROR: %s, must be %s" , subject, - opt->verify_x509_name); -return FAILURE ;/* Reject connection */ +msg (D_HANDSHAKE , err_fmt, match_str, opt->verify_x509_name); +return FAILURE ; } +msg (D_HANDSHAKE ,"VERIFY X509NAME OK: %s" , subject); }return SUCCESS ;
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1624?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6e7947ab81cf229f0d27714dd563a07ace6bd38a
Gerrit-Change-Number: 1624
Gerrit-PatchSet: 2
Gerrit-Owner: selvanair <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1624?usp=email )
Change subject: verify_x509_name: Improve the error message on failure
......................................................................
verify_x509_name: Improve the error message on failure
Print the actual string that was used for the match instead of the whole subject.
Github: closes OpenVPN/openvpn#992
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1624
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36606.html
---
M src/openvpn/ssl_verify.c
1 file changed, 22 insertions(+), 11 deletions(-)
src/openvpn/ssl_verify.c +22 -11
@@ -369,21 +369,32 @@/* verify X509 name or username against --verify-x509-[user]name */ if (opt->verify_x509_type !=VERIFY_X509_NONE ) { -if ((opt->verify_x509_type ==VERIFY_X509_SUBJECT_DN - &&strcmp (opt->verify_x509_name, subject) ==0 ) - || (opt->verify_x509_type ==VERIFY_X509_SUBJECT_RDN - &&strcmp (opt->verify_x509_name, common_name) ==0 ) - || (opt->verify_x509_type ==VERIFY_X509_SUBJECT_RDN_PREFIX - &&strncmp (opt->verify_x509_name, common_name,strlen (opt->verify_x509_name)) ==0 )) +const char *err_fmt ="VERIFY X509NAME ERROR: %s, must be %s" ; +const char *match_str = common_name; +bool verified = false; +switch (opt->verify_x509_type) { -msg (D_HANDSHAKE ,"VERIFY X509NAME OK: %s" , subject); +case VERIFY_X509_SUBJECT_DN : + match_str = subject; + verified = !strcmp (opt->verify_x509_name, match_str); +break ; +case VERIFY_X509_SUBJECT_RDN : + verified = !strcmp (opt->verify_x509_name, match_str); +break ; +case VERIFY_X509_SUBJECT_RDN_PREFIX : + err_fmt ="VERIFY X509NAME ERROR: %s, must start with %s" ; + verified = !strncmp (opt->verify_x509_name, match_str,strlen (opt->verify_x509_name)); +break ; +default : +ASSERT (0 );/* should not happen */ +break ; } -else +if (!verified) { -msg (D_HANDSHAKE ,"VERIFY X509NAME ERROR: %s, must be %s" , subject, - opt->verify_x509_name); -return FAILURE ;/* Reject connection */ +msg (D_HANDSHAKE , err_fmt, match_str, opt->verify_x509_name); +return FAILURE ; } +msg (D_HANDSHAKE ,"VERIFY X509NAME OK: %s" , subject); }return SUCCESS ;
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1624?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6e7947ab81cf229f0d27714dd563a07ace6bd38a
Gerrit-Change-Number: 1624
Gerrit-PatchSet: 2
Gerrit-Owner: selvanair <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: ordex <[email protected]...>